package intelligentcity.cities;

import intelligentcity.conf.Conf;
import intelligentcity.model.CityBuilder;
import intelligentcity.model.intersections.Intersection;
import intelligentcity.model.streets.HorizontalStreet;
import intelligentcity.model.streets.VerticalStreet;
import intelligentcity.model.turns.Turn;
import intelligentcity.model.turns.Turn.Corner;
import intelligentcity.system.LightsLearnedByRatio;

public class Oklahoma2CityBuilder extends CityBuilder {

    public Oklahoma2CityBuilder() {
        super();

        leftBorderOfTraffic = 5;
        rightBorderOfTraffic = 915;
        upperBorderOfTraffic = 5;
        lowerBorderOfTraffic = 765;

        int firstHorizontalParam = 200;
        int secondHorizontalParam = 560;

        int vertX1 = 180;
        int vertX2 = 440;
        int vertX3 = 700;

        int vertY0 = 0;
        int vertY1 = 160;
        int vertY2 = 280;
        int vertY3 = 360;

        int vertY4 = 520;
        int vertY5 = 640;
        int vertY6 = 770;

        addStreet(new HorizontalStreet(0, firstHorizontalParam, 140, Conf.MAIN));

        addStreet(new VerticalStreet(vertX1, vertY0, vertY1));
        Intersection int1 = new Intersection(new VerticalStreet(vertX1, vertY1, vertY2), new HorizontalStreet(140,
                firstHorizontalParam, 260));
        addIntersection(int1);
        addStreet(new VerticalStreet(vertX1, vertY2, vertY3));

        addStreet(new HorizontalStreet(260, firstHorizontalParam, 400));

        addStreet(new VerticalStreet(vertX2, vertY0, vertY1));
        Intersection int2 = new Intersection(new VerticalStreet(vertX2, vertY1, vertY2), new HorizontalStreet(400,
                firstHorizontalParam, 520));
        addIntersection(int2);
        addStreet(new VerticalStreet(vertX2, vertY2, vertY3));

        addStreet(new HorizontalStreet(520, firstHorizontalParam, 660));

        addStreet(new VerticalStreet(vertX3, vertY0, vertY1));
        Intersection int3 = new Intersection(new VerticalStreet(vertX3, vertY1, vertY2), new HorizontalStreet(660,
                firstHorizontalParam, 780));
        addIntersection(int3);
        addStreet(new VerticalStreet(vertX3, vertY2, vertY3));

        addStreet(new HorizontalStreet(780, firstHorizontalParam, 920, Conf.MAIN));

        // --------------

        addStreet(new VerticalStreet(vertX2, vertY3, vertY4));
        Intersection int4 = new Intersection(new VerticalStreet(vertX2, vertY4, vertY5), new HorizontalStreet(400,
                secondHorizontalParam, 520));
        addIntersection(int4);
        addStreet(new VerticalStreet(vertX2, vertY5, vertY6));

        addTurn(new Turn(Corner.SW, 180, 560 + Conf.distanceBeetweenStreets, 200 + Conf.distanceBeetweenStreets, 220));

        addTurn(new Turn(Corner.SE, 740, 560 + Conf.distanceBeetweenStreets, 200 + Conf.distanceBeetweenStreets, 220));

        int1.setLights(new LightsLearnedByRatio());
        int2.setLights(new LightsLearnedByRatio());
        int3.setLights(new LightsLearnedByRatio());
        int4.setLights(new LightsLearnedByRatio());
    }

}
